package com.budwk.app.waterquality.controllers.admin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.budwk.app.waterquality.config.AppException;
import com.budwk.app.waterquality.models.ControlCenterInfo;
import com.budwk.app.waterquality.services.ControlCenterInfoService;
import com.budwk.app.waterquality.vo.ControlCenterInfoQueryVo;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.page.PageUtil;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import com.budwk.starter.security.utils.SecurityUtil;
import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.impl.AdaptorErrorContext;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;

import javax.servlet.http.HttpServletRequest;

@IocBean
@At("/waterquality/admin/control/center/info")
@ApiDefinition(tag = "质控中心")
@SLog(tag = "质控中心")
@Slf4j
public class ControlCenterInfoController {
    @Inject
    private ControlCenterInfoService wkControlCenterInfoService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "分页查询质控中心")
    public Result<?> listByPage(@Param("..") ControlCenterInfoQueryVo reqVo) {
        return Result.data(wkControlCenterInfoService.listByPage(reqVo));
    }

    @At
    @Ok("json")
    @POST
    @SLog(value = "新增")
    @ApiOperation(name = "新增")
    @ApiResponses
    public Result<?> create(@Param("..")ControlCenterInfo w) {
        wkControlCenterInfoService.create(w);
        return Result.success();
    }

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "获取质控中心")
    public Result<?> getData(@Param("id")String id, HttpServletRequest req) {
        ControlCenterInfo wkControlCenterInfo = wkControlCenterInfoService.fetch(id);
        return Result.data(wkControlCenterInfo);
    }

    @At
    @Ok("json")
    @DELETE
    @ApiOperation(name = "删除质控中心")
    public Result<?> delete(@Param("id")String id, HttpServletRequest req) {
        wkControlCenterInfoService.deleteData(id);
        return Result.success();
    }
}
